package com.atguigu.springcloud.entity;

import java.util.HashMap;

public class CommonResult  extends HashMap<String,Object>   {
private static final long serialVersionUID = 1L;

	public CommonResult() {
		put("code", 0);
		put("msg", "success");
	}
	@Override
	public CommonResult put(String key, Object value) {
		super.put(key, value);
		return this;
	}
	public static CommonResult error() {
		return error(500, "未知异常，请联系管理员");
	}
	
	public static CommonResult error(String msg) {
		return error(500, msg);
	}
	
	public static CommonResult error(int code, String msg) {
		CommonResult r = new CommonResult();
		r.put("code", code).put("msg", msg);
		return r;
	}


	public static CommonResult ok() {
		return new CommonResult();
	}
	
	public static CommonResult ok(Object args) {
		return new CommonResult().put("data", args);
	}
	public static CommonResult ok(String msg,Object args) {
		CommonResult r = new CommonResult();
		r.put("msg", msg).put("data", args);
		return r;
	}	
}
